import {GetUserInfo, Login} from "@/api";
import {SET_EXPIRE_TIME, SET_INFO, SET_TOKEN} from '@/utils/auth';

export const LOGIN = (params: any) => {
    return new Promise((resolve, reject) => {
        Login(params).then((res:any) => {
            if (res.code === 0) {
                SET_TOKEN(res.token)
                resolve(res)

            } else {
                reject('登录失败')
            }
        }).catch((err: any) => {
            reject(err)
        })
    })
}
export const GetInfo = () => {
    return new Promise((resolve, reject) => {
        GetUserInfo().then((response:any) => {
            const result = response
            if (result.userId) {
                SET_INFO(result)
            }
            resolve(response)
        }).catch((err: any) => {
            reject(err)
        })
    })
}
